import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { CommissionRecordApi } from '#/api/spa/commission/record';

import { z } from '#/adapter/form';
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'recordCode',
      label: '记录编码',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入记录编码',
      },
    },
    {
      fieldName: 'staffId',
      label: '员工ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入员工ID',
      },
    },
    {
      fieldName: 'staffType',
      label: '员工类型',
      rules: 'required',
      // component: 'Select',
      // componentProps: {
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
      //   placeholder: '请选择员工类型',
      // },
    },
    {
      fieldName: 'commissionType',
      label: '提成类型',
      rules: 'required',
      // component: 'Select',
      // componentProps: {
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
      //   placeholder: '请选择提成类型',
      // },
    },
    {
      fieldName: 'baseAmount',
      label: '基础金额',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入基础金额',
      },
    },
    {
      fieldName: 'commissionRate',
      label: '提成比例',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入提成比例',
      },
    },
    {
      fieldName: 'commissionAmount',
      label: '提成金额',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入提成金额',
      },
    },
    {
      fieldName: 'bonusAmount',
      label: '奖励金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入奖励金额',
      },
    },
    {
      fieldName: 'adjustmentAmount',
      label: '调整金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入调整金额',
      },
    },
    {
      fieldName: 'totalCommission',
      label: '总提成金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入总提成金额',
      },
    },
    {
      fieldName: 'businessId',
      label: '业务ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入业务ID',
      },
    },
    {
      fieldName: 'businessType',
      label: '业务类型',
      // rules: 'required',
      // component: 'Select',
      // componentProps: {
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
      //   placeholder: '请选择业务类型',
      // },
    },
    {
      fieldName: 'businessDate',
      label: '业务日期',
      rules: 'required',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'ruleId',
      label: '提成规则ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入提成规则ID',
      },
    },
    {
      fieldName: 'policyId',
      label: '策略ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入策略ID',
      },
    },
    {
      fieldName: 'decisionLogId',
      label: '决策日志ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入决策日志ID',
      },
    },
    {
      fieldName: 'status',
      label: '状态',
      // component: 'RadioGroup',
      // componentProps: {
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
      //   buttonStyle: 'solid',
      //   optionType: 'button',
      // },
    },
    {
      fieldName: 'confirmTime',
      label: '确认时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'payTime',
      label: '发放时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'calculationDetails',
      label: '计算详情',
      component: 'Input',
      componentProps: {
        placeholder: '请输入计算详情',
      },
    },
    {
      fieldName: 'groupId',
      label: '集团ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入集团ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入组织ID',
      },
    },
    {
      fieldName: 'customerId',
      label: '客户ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户ID',
      },
    },
    {
      fieldName: 'customerName',
      label: '客户姓名',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户姓名',
      },
    },
    {
      fieldName: 'serviceId',
      label: '服务ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务ID',
      },
    },
    {
      fieldName: 'serviceName',
      label: '服务名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务名称',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'recordCode',
      label: '记录编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入记录编码',
      },
    },
    {
      fieldName: 'staffId',
      label: '员工ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入员工ID',
      },
    },
    {
      fieldName: 'staffType',
      label: '员工类型',
      // component: 'Select',
      // componentProps: {
      //   allowClear: true,
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
      //   placeholder: '请选择员工类型',
      // },
    },
    {
      fieldName: 'commissionType',
      label: '提成类型',
      // component: 'Select',
      // componentProps: {
      //   allowClear: true,
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
      //   placeholder: '请选择提成类型',
      // },
    },
    {
      fieldName: 'baseAmount',
      label: '基础金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入基础金额',
      },
    },
    {
      fieldName: 'commissionRate',
      label: '提成比例',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入提成比例',
      },
    },
    {
      fieldName: 'commissionAmount',
      label: '提成金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入提成金额',
      },
    },
    {
      fieldName: 'bonusAmount',
      label: '奖励金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入奖励金额',
      },
    },
    {
      fieldName: 'adjustmentAmount',
      label: '调整金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入调整金额',
      },
    },
    {
      fieldName: 'totalCommission',
      label: '总提成金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入总提成金额',
      },
    },
    {
      fieldName: 'businessId',
      label: '业务ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入业务ID',
      },
    },
    {
      fieldName: 'businessType',
      label: '业务类型',
      // component: 'Select',
      // componentProps: {
      //   allowClear: true,
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
      //   placeholder: '请选择业务类型',
      // },
    },
    {
      fieldName: 'businessDate',
      label: '业务日期',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'ruleId',
      label: '提成规则ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入提成规则ID',
      },
    },
    {
      fieldName: 'policyId',
      label: '策略ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入策略ID',
      },
    },
    {
      fieldName: 'decisionLogId',
      label: '决策日志ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入决策日志ID',
      },
    },
    {
      fieldName: 'status',
      label: '状态',
      // component: 'Select',
      // componentProps: {
      //   allowClear: true,
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
      //   placeholder: '请选择状态',
      // },
    },
    {
      fieldName: 'confirmTime',
      label: '确认时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'payTime',
      label: '发放时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'calculationDetails',
      label: '计算详情',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入计算详情',
      },
    },
    {
      fieldName: 'groupId',
      label: '集团ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入集团ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入组织ID',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'customerId',
      label: '客户ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户ID',
      },
    },
    {
      fieldName: 'customerName',
      label: '客户姓名',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户姓名',
      },
    },
    {
      fieldName: 'serviceId',
      label: '服务ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务ID',
      },
    },
    {
      fieldName: 'serviceName',
      label: '服务名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务名称',
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<CommissionRecordApi.CommissionRecord>['columns'] {
  return [
    {
      field: 'id',
      title: '主键ID',
      minWidth: 120,
    },
    {
      field: 'recordCode',
      title: '记录编码',
      minWidth: 120,
    },
    {
      field: 'staffId',
      title: '员工ID',
      minWidth: 120,
    },
    {
      field: 'staffType',
      title: '员工类型',
      minWidth: 120,
    },
    {
      field: 'commissionType',
      title: '提成类型',
      minWidth: 120,
    },
    {
      field: 'baseAmount',
      title: '基础金额',
      minWidth: 120,
    },
    {
      field: 'commissionRate',
      title: '提成比例',
      minWidth: 120,
    },
    {
      field: 'commissionAmount',
      title: '提成金额',
      minWidth: 120,
    },
    {
      field: 'bonusAmount',
      title: '奖励金额',
      minWidth: 120,
    },
    {
      field: 'adjustmentAmount',
      title: '调整金额',
      minWidth: 120,
    },
    {
      field: 'totalCommission',
      title: '总提成金额',
      minWidth: 120,
    },
    {
      field: 'businessId',
      title: '业务ID',
      minWidth: 120,
    },
    {
      field: 'businessType',
      title: '业务类型',
      minWidth: 120,
    },
    {
      field: 'businessDate',
      title: '业务日期',
      minWidth: 120,
    },
    {
      field: 'ruleId',
      title: '提成规则ID',
      minWidth: 120,
    },
    {
      field: 'policyId',
      title: '策略ID',
      minWidth: 120,
    },
    {
      field: 'decisionLogId',
      title: '决策日志ID',
      minWidth: 120,
    },
    {
      field: 'status',
      title: '状态',
      minWidth: 120,
    },
    {
      field: 'confirmTime',
      title: '确认时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'payTime',
      title: '发放时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'calculationDetails',
      title: '计算详情',
      minWidth: 120,
    },
    {
      field: 'groupId',
      title: '集团ID',
      minWidth: 120,
    },
    {
      field: 'storeId',
      title: '门店ID',
      minWidth: 120,
    },
    {
      field: 'orgId',
      title: '组织ID',
      minWidth: 120,
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'customerId',
      title: '客户ID',
      minWidth: 120,
    },
    {
      field: 'customerName',
      title: '客户姓名',
      minWidth: 120,
    },
    {
      field: 'serviceId',
      title: '服务ID',
      minWidth: 120,
    },
    {
      field: 'serviceName',
      title: '服务名称',
      minWidth: 120,
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
